<template>
  <div class="sys-page">
    <div class="lamp-btn-box">
      <div class="lamp-btn" v-for="(item,idx) in defaultData"
           @click="lampHandle(item,idx)"
           :class="{'on': lampIdx == idx}">
        {{ item.buildingName }}
      </div>
    </div>
    <div style="height: calc(100% - 61px)">
      <base-table :pagination="pagination">
        <el-table :data="tableData" stripe border
                  :cell-style="{ textAlign: 'center' }"
                  :header-cell-style="{ textAlign: 'center' }"
                  header-row-class-name="headerRow"
                  class="lamp-table"
                  style="width: 100%; height: 100%">
<!--          <el-table-column type="index" width="150" label="序号" #default="scope">
&lt;!&ndash;            {{ scope.$index < 9 ? '0' + (scope.$index + 1) : scope.$index + 1 }}&ndash;&gt;

            <el-table-column prop="buildingName" label="名称" />
            <el-table-column prop="totalElectricA" label="totalElectricA" />
            <el-table-column prop="totalElectricB" label="totalElectricB" />
            <el-table-column prop="totalElectricC" label="totalElectricC" />
          </el-table-column>-->


          <el-table-column prop="buildingName" :label="columnName" >
            <el-table-column prop="ammeternameFact" label="三相电流" />
            <el-table-column prop="gatewayLocation" label="箱体位置" v-if="lampType == 'bridge'" />
            <el-table-column prop="reading" label="电表读数" />
<!--            <el-table-column prop="reading" label="A相电流总和"  v-if="lampType == 'bridge'"></el-table-column>-->
<!--            <el-table-column prop="reading" label="B相电流总和"  v-if="lampType == 'bridge'"></el-table-column>-->
<!--            <el-table-column prop="reading" label="C相电流总和"  v-if="lampType == 'bridge'"></el-table-column>-->
          </el-table-column>
        </el-table>
      </base-table>
    </div>
  </div>

</template>

<script>
import BaseTable from "../../components/baseTable.vue";
import {
  BrigeZongLan,
  judgeLightOnline,
  refreshGatewayData,
  sendCommandLightMsg,
  TowerZongLan, updateLightType,lampElectric
} from "../../router/api.js";
import {mapGetters} from "vuex";

export default {
  name: "index",
  computed: {
    ...mapGetters(['currentNav','userInfo','refreshFlag'])
  },
  components: {BaseTable},
  data() {
    return {
      lampBtn: [],
      lampIdx: 0,
      pagination: {
        pages: 1,
        pageSize: 18,
        total: 0,
      },
      tableData: [],
      selLamp: [],
      fetchingFlag: true,
      defaultData: [],
      lampType: 'tower',
      columnName:'',
    }
  },
  watch:{
    'currentNav': {
      deep: true,
      handler(){
        this.lampIdx = 0;
        this.selLamp = [];
        this.getLampData()
      }
    },
    'refreshFlag': {
      deep: true,
      handler(n) {
        if(n) {
          this.getLampData();
          refreshGatewayData();
          // judgeLightOnline();

          this.$store.commit('SET_WAIT', true)
        }
      }
    }
  },
  beforeRouteLeave(to, from, next) {
    clearInterval(this.timer);
    this.timer = null;
    this.fetchingFlag = false;

    next();
  },
  created() {
    this.getLampData();

    this.timer = setInterval(() => {
      if(this.fetchingFlag){
        this.getLampData();
      }
    }, 1000 * 5)
  },
  methods: {
    async getLampData() {
      this.fetchingFlag = true;

      let res = await lampElectric();
      /*let res = {
        status: 200,
        data:  [
          {
            "buildingName": "一区1#灯塔",
            "type": "tower",
            "dbAmmeterList": [
              {
                "ammeterId": 80,
                "gatewayId": 1,
                "ccid": "/1/tower1/D1",
                "ammetername": "C14",
                "ammeternameFact": "A相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": null
              },
              {
                "ammeterId": 81,
                "gatewayId": 1,
                "ccid": "/1/tower1/D1",
                "ammetername": "C15",
                "ammeternameFact": "B相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": null
              },
              {
                "ammeterId": 82,
                "gatewayId": 1,
                "ccid": "/1/tower1/D1",
                "ammetername": "C16",
                "ammeternameFact": "C相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": null
              }
            ],
            "totalElectricA": 0.0,
            "totalElectricB": 0.0,
            "totalElectricC": 0.0
          },
          {
            "buildingName": "二区1#灯塔",
            "type": "tower",
            "dbAmmeterList": [
              {
                "ammeterId": 83,
                "gatewayId": 2,
                "ccid": "/2/tower1/D1",
                "ammetername": "C14",
                "ammeternameFact": "A相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": null
              },
              {
                "ammeterId": 84,
                "gatewayId": 2,
                "ccid": "/2/tower1/D1",
                "ammetername": "C15",
                "ammeternameFact": "B相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": null
              },
              {
                "ammeterId": 85,
                "gatewayId": 2,
                "ccid": "/2/tower1/D1",
                "ammetername": "C16",
                "ammeternameFact": "C相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": null
              }
            ],
            "totalElectricA": 0.0,
            "totalElectricB": 0.0,
            "totalElectricC": 0.0
          },
          {
            "buildingName": "二区2#灯塔",
            "type": "tower",
            "dbAmmeterList": [
              {
                "ammeterId": 98,
                "gatewayId": 5,
                "ccid": "/2/tower2/D1",
                "ammetername": "C14",
                "ammeternameFact": "A相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-26T10:05:50.000+00:00"
              },
              {
                "ammeterId": 99,
                "gatewayId": 5,
                "ccid": "/2/tower2/D1",
                "ammetername": "C15",
                "ammeternameFact": "B相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-26T10:05:50.000+00:00"
              },
              {
                "ammeterId": 100,
                "gatewayId": 5,
                "ccid": "/2/tower2/D1",
                "ammetername": "C16",
                "ammeternameFact": "C相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-26T10:05:50.000+00:00"
              }
            ],
            "totalElectricA": 0.0,
            "totalElectricB": 0.0,
            "totalElectricC": 0.0
          },
          {
            "buildingName": "二区3#灯塔",
            "type": "tower",
            "dbAmmeterList": [
              {
                "ammeterId": 101,
                "gatewayId": 6,
                "ccid": "/2/tower3/D1",
                "ammetername": "C14",
                "ammeternameFact": "A相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-25T15:31:16.000+00:00"
              },
              {
                "ammeterId": 102,
                "gatewayId": 6,
                "ccid": "/2/tower3/D1",
                "ammetername": "C15",
                "ammeternameFact": "B相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-25T15:31:16.000+00:00"
              },
              {
                "ammeterId": 103,
                "gatewayId": 6,
                "ccid": "/2/tower3/D1",
                "ammetername": "C16",
                "ammeternameFact": "C相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-25T15:31:16.000+00:00"
              }
            ],
            "totalElectricA": 0.0,
            "totalElectricB": 0.0,
            "totalElectricC": 0.0
          },
          {
            "buildingName": "二区4#灯塔",
            "type": "tower",
            "dbAmmeterList": [
              {
                "ammeterId": 104,
                "gatewayId": 7,
                "ccid": "/2/tower4/D1",
                "ammetername": "C14",
                "ammeternameFact": "A相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-25T19:01:51.000+00:00"
              },
              {
                "ammeterId": 105,
                "gatewayId": 7,
                "ccid": "/2/tower4/D1",
                "ammetername": "C15",
                "ammeternameFact": "B相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-25T19:01:51.000+00:00"
              },
              {
                "ammeterId": 106,
                "gatewayId": 7,
                "ccid": "/2/tower4/D1",
                "ammetername": "C16",
                "ammeternameFact": "C相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-25T19:01:51.000+00:00"
              }
            ],
            "totalElectricA": 0.0,
            "totalElectricB": 0.0,
            "totalElectricC": 0.0
          },
          {
            "buildingName": "二区5#灯塔",
            "type": "tower",
            "dbAmmeterList": [
              {
                "ammeterId": 107,
                "gatewayId": 8,
                "ccid": "/2/tower5/D1",
                "ammetername": "C14",
                "ammeternameFact": "A相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-25T16:23:29.000+00:00"
              },
              {
                "ammeterId": 108,
                "gatewayId": 8,
                "ccid": "/2/tower5/D1",
                "ammetername": "C15",
                "ammeternameFact": "B相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-25T16:23:29.000+00:00"
              },
              {
                "ammeterId": 109,
                "gatewayId": 8,
                "ccid": "/2/tower5/D1",
                "ammetername": "C16",
                "ammeternameFact": "C相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-25T16:23:29.000+00:00"
              }
            ],
            "totalElectricA": 0.0,
            "totalElectricB": 0.0,
            "totalElectricC": 0.0
          },
          {
            "buildingName": "散货区1#灯塔",
            "type": "tower",
            "dbAmmeterList": [
              {
                "ammeterId": 110,
                "gatewayId": 11,
                "ccid": "/3/tower1/D1",
                "ammetername": "C14",
                "ammeternameFact": "A相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-26T11:31:56.000+00:00"
              },
              {
                "ammeterId": 111,
                "gatewayId": 11,
                "ccid": "/3/tower1/D1",
                "ammetername": "C15",
                "ammeternameFact": "B相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-26T11:31:56.000+00:00"
              },
              {
                "ammeterId": 112,
                "gatewayId": 11,
                "ccid": "/3/tower1/D1",
                "ammetername": "C16",
                "ammeternameFact": "C相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-26T11:31:56.000+00:00"
              }
            ],
            "totalElectricA": 0.0,
            "totalElectricB": 0.0,
            "totalElectricC": 0.0
          },
          {
            "buildingName": "散货区2#灯塔",
            "type": "tower",
            "dbAmmeterList": [
              {
                "ammeterId": 113,
                "gatewayId": 12,
                "ccid": "/3/tower2/D1",
                "ammetername": "C14",
                "ammeternameFact": "A相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-26T11:07:09.000+00:00"
              },
              {
                "ammeterId": 114,
                "gatewayId": 12,
                "ccid": "/3/tower2/D1",
                "ammetername": "C15",
                "ammeternameFact": "B相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-26T11:07:09.000+00:00"
              },
              {
                "ammeterId": 115,
                "gatewayId": 12,
                "ccid": "/3/tower2/D1",
                "ammetername": "C16",
                "ammeternameFact": "C相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-26T11:07:09.000+00:00"
              }
            ],
            "totalElectricA": 0.0,
            "totalElectricB": 0.0,
            "totalElectricC": 0.0
          },
          {
            "buildingName": "散货区3#灯塔",
            "type": "tower",
            "dbAmmeterList": [
              {
                "ammeterId": 116,
                "gatewayId": 13,
                "ccid": "/3/tower3/D1",
                "ammetername": "C14",
                "ammeternameFact": "A相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-25T22:52:18.000+00:00"
              },
              {
                "ammeterId": 117,
                "gatewayId": 13,
                "ccid": "/3/tower3/D1",
                "ammetername": "C15",
                "ammeternameFact": "B相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-25T22:52:18.000+00:00"
              },
              {
                "ammeterId": 118,
                "gatewayId": 13,
                "ccid": "/3/tower3/D1",
                "ammetername": "C16",
                "ammeternameFact": "C相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": "2024-12-25T22:52:18.000+00:00"
              }
            ],
            "totalElectricA": 0.0,
            "totalElectricB": 0.0,
            "totalElectricC": 0.0
          },
          {
            "buildingName": "一区灯桥",
            "type": "bridge",
            "dbAmmeterList": [
              {
                "ammeterId": 86,
                "gatewayId": 3,
                "ccid": "/1/brige1/D1",
                "ammetername": "C16",
                "ammeternameFact": "A相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": null
              },
              {
                "ammeterId": 87,
                "gatewayId": 3,
                "ccid": "/1/brige1/D1",
                "ammetername": "C17",
                "ammeternameFact": "B相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": null
              },
              {
                "ammeterId": 88,
                "gatewayId": 3,
                "ccid": "/1/brige1/D1",
                "ammetername": "C18",
                "ammeternameFact": "C相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": null
              },
              {
                "ammeterId": 89,
                "gatewayId": 3,
                "ccid": "/1/brige1/D1",
                "ammetername": "C19",
                "ammeternameFact": "A相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 2,
                "updatetime": null
              },
              {
                "ammeterId": 90,
                "gatewayId": 3,
                "ccid": "/1/brige1/D1",
                "ammetername": "C20",
                "ammeternameFact": "B相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 2,
                "updatetime": null
              },
              {
                "ammeterId": 91,
                "gatewayId": 3,
                "ccid": "/1/brige1/D1",
                "ammetername": "C21",
                "ammeternameFact": "C相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 2,
                "updatetime": null
              },
              {
                "ammeterId": 92,
                "gatewayId": 4,
                "ccid": "/1/brige1/D2",
                "ammetername": "C16",
                "ammeternameFact": "A相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 3,
                "updatetime": null
              },
              {
                "ammeterId": 93,
                "gatewayId": 4,
                "ccid": "/1/brige1/D2",
                "ammetername": "C17",
                "ammeternameFact": "B相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 3,
                "updatetime": null
              },
              {
                "ammeterId": 94,
                "gatewayId": 4,
                "ccid": "/1/brige1/D2",
                "ammetername": "C18",
                "ammeternameFact": "C相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 3,
                "updatetime": null
              },
              {
                "ammeterId": 95,
                "gatewayId": 4,
                "ccid": "/1/brige1/D2",
                "ammetername": "C19",
                "ammeternameFact": "A相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 4,
                "updatetime": null
              },
              {
                "ammeterId": 96,
                "gatewayId": 4,
                "ccid": "/1/brige1/D2",
                "ammetername": "C20",
                "ammeternameFact": "B相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 4,
                "updatetime": null
              },
              {
                "ammeterId": 97,
                "gatewayId": 4,
                "ccid": "/1/brige1/D2",
                "ammetername": "C21",
                "ammeternameFact": "C相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 4,
                "updatetime": null
              }
            ],
            "totalElectricA": 4.0,
            "totalElectricB": 4.0,
            "totalElectricC": 4.0
          },
          {
            "buildingName": "二区灯桥",
            "type": "bridge",
            "dbAmmeterList": [
              {
                "ammeterId": 74,
                "gatewayId": 9,
                "ccid": "/2/brige1/D1",
                "ammetername": "C16",
                "ammeternameFact": "A相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": null
              },
              {
                "ammeterId": 75,
                "gatewayId": 9,
                "ccid": "/2/brige1/D1",
                "ammetername": "C17",
                "ammeternameFact": "B相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": null
              },
              {
                "ammeterId": 76,
                "gatewayId": 9,
                "ccid": "/2/brige1/D1",
                "ammetername": "C18",
                "ammeternameFact": "C相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 1,
                "updatetime": null
              },
              {
                "ammeterId": 77,
                "gatewayId": 9,
                "ccid": "/2/brige1/D1",
                "ammetername": "C19",
                "ammeternameFact": "A相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 2,
                "updatetime": null
              },
              {
                "ammeterId": 78,
                "gatewayId": 9,
                "ccid": "/2/brige1/D1",
                "ammetername": "C20",
                "ammeternameFact": "B相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 2,
                "updatetime": null
              },
              {
                "ammeterId": 79,
                "gatewayId": 9,
                "ccid": "/2/brige1/D1",
                "ammetername": "C21",
                "ammeternameFact": "C相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 2,
                "updatetime": null
              },
              {
                "ammeterId": 65,
                "gatewayId": 10,
                "ccid": "/2/brige1/D2",
                "ammetername": "C18",
                "ammeternameFact": "A相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 3,
                "updatetime": null
              },
              {
                "ammeterId": 66,
                "gatewayId": 10,
                "ccid": "/2/brige1/D2",
                "ammetername": "C19",
                "ammeternameFact": "B相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 3,
                "updatetime": null
              },
              {
                "ammeterId": 67,
                "gatewayId": 10,
                "ccid": "/2/brige1/D2",
                "ammetername": "C20",
                "ammeternameFact": "C相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 3,
                "updatetime": null
              },
              {
                "ammeterId": 68,
                "gatewayId": 10,
                "ccid": "/2/brige1/D2",
                "ammetername": "C21",
                "ammeternameFact": "A相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 4,
                "updatetime": null
              },
              {
                "ammeterId": 69,
                "gatewayId": 10,
                "ccid": "/2/brige1/D2",
                "ammetername": "C22",
                "ammeternameFact": "B相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 4,
                "updatetime": null
              },
              {
                "ammeterId": 70,
                "gatewayId": 10,
                "ccid": "/2/brige1/D2",
                "ammetername": "C23",
                "ammeternameFact": "C相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 4,
                "updatetime": null
              },
              {
                "ammeterId": 71,
                "gatewayId": 10,
                "ccid": "/2/brige1/D2",
                "ammetername": "C24",
                "ammeternameFact": "A相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 5,
                "updatetime": null
              },
              {
                "ammeterId": 72,
                "gatewayId": 10,
                "ccid": "/2/brige1/D2",
                "ammetername": "C25",
                "ammeternameFact": "B相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 5,
                "updatetime": null
              },
              {
                "ammeterId": 73,
                "gatewayId": 10,
                "ccid": "/2/brige1/D2",
                "ammetername": "C26",
                "ammeternameFact": "C相电流",
                "lightonNumber": null,
                "reading": 1.0,
                "ammeterreadingType": 4,
                "gatewayLocation": 5,
                "updatetime": null
              }
            ],
            "totalElectricA": 5.0,
            "totalElectricB": 5.0,
            "totalElectricC": 5.0
          }
        ]
      }*/
      console.log(res.data)
      if(res.status == 200){
        this.defaultData = res.data;
        let {buildingName,type,dbAmmeterList,totalElectricA,totalElectricB,totalElectricC} = this.defaultData[this.lampIdx]
        this.columnName = buildingName;
        this.lampType = type;
        this.tableData = dbAmmeterList;
        if(type == 'bridge'){
          this.tableData.push(
              {
                ammeternameFact: 'A相电流总和',
                gatewayLocation: '无',
                reading: totalElectricA,
              },
              {
                ammeternameFact: 'B相电流总和',
                gatewayLocation: '无',
                reading: totalElectricB,
              },
              {
                ammeternameFact: 'C相电流总和',
                gatewayLocation: '无',
                reading: totalElectricC,
              }
          )
        }
      }
    },
    lampHandle(item,idx) {
      this.lampIdx = idx;
      let {buildingName,type,dbAmmeterList,totalElectricA,totalElectricB,totalElectricC} = item;
      this.columnName = buildingName;
      this.lampType = type;
      this.tableData = dbAmmeterList;
      if(type == 'bridge'){
        this.tableData.push(
            {
              ammeternameFact: 'A相电流总和',
              gatewayLocation: '无',
              reading: totalElectricA,
            },
            {
              ammeternameFact: 'B相电流总和',
              gatewayLocation: '无',
              reading: totalElectricB,
            },
            {
              ammeternameFact: 'C相电流总和',
              gatewayLocation: '无',
              reading: totalElectricC,
            }
        )
      }
    },
  }
}
</script>

<style scop lang="scss">
.lamp-btn-box {
  display: flex;
  margin: 12px auto 17px;
  position: relative;
  z-index: 8;

  .lamp-btn {
    width: 104px;
    height: 42px;
    line-height: 42px;
    text-align: center;
    color: #336666;
    font-size: 16px;
    font-weight: 400;
    margin-right: 2px;
    background: url("@/assets/images/img-area-bg-def.svg") no-repeat left top;
    background-size: 100% 100%;
    cursor: pointer;

    &:hover, &.on {
      background: url("@/assets/images/img-area-bg.svg") no-repeat left top;
      background-size: 100% 100%;
    }
  }
}

.sys-page {
  margin-left: 10px;
  height: 100%;

  .lamp-table {
    height: calc(100% - 74px);
  }
}

</style>
<style>
.headerRow {
  background: linear-gradient(to right, #6B92F0, #76D0FF) !important;
}

.el-table th.el-table__cell {
  background-color: transparent;
  color: #fff;
}

.el-table thead.is-group th.el-table__cell {
  background-color: transparent;
  color: #fff;
}
</style>
